package util

import (
	"github.com/fatih/color"
)

var DataPath string
var LogPath string

const (
	MsgA = "a.重要紧急:"
	MsgB = "b.不重要紧急:"
	MsgC = "c.重要不紧急:"
	MsgD = "d.不重要不紧急:"

	TypeA = "a"
	TypeB = "b"
	TypeC = "c"
	TypeD = "d"

	MsgHelp = "错误的命令，使用snail help查询使用命令"

	LogTypeAdd    = "add"
	LogTypeDelete = "delete"
	LogTypeFinish = "finish"
	LogTypeModify = "modify"
	LogTypeMove   = "move"
	LogTypeBegin  = "begin"
)

// 结构体 A重要紧急 B重要不紧急 C不重要紧急 D不重要不紧急
type SnailData struct {
	TypeA []TypeData `json:"typeA"`
	TypeB []TypeData `json:"typeB"`
	TypeC []TypeData `json:"typeC"`
	TypeD []TypeData `json:"typeD"`
}

type TypeData struct {
	Val        string `json:"val"`
	Remark     string `json:"Remark"` // 备注
	CreateTime int64  `json:"createTime"`
	LastTime   int64  `json:"lastTime"`
	UniqId     int64  `json:"uniqId"`
	Grids      []Grid `json:"Grids"`
}

// 爬格子，代表处理任务的次数
type Grid struct {
	Create int64 `json:"create"`
}

// 统计权重数据
type SortData struct {
	DataType string   `json:"dataType"` // 类型
	Num      int      `json:"num"`      // 序号
	Weight   int      `json:"weight"`   // 权重
	Data     TypeData `json:"data"`     // 数据
}

var TypeColorMap = map[string]color.Attribute{
	TypeA: color.FgRed,
	TypeB: color.FgGreen,
	TypeC: color.FgYellow,
	TypeD: color.FgCyan,
}

var LogTypeColorMap = map[string]color.Attribute{
	LogTypeAdd:    color.FgGreen,
	LogTypeDelete: color.FgRed,
	LogTypeFinish: color.FgYellow,
	LogTypeModify: color.FgCyan,
	LogTypeMove:   color.FgMagenta,
	LogTypeBegin:  color.FgWhite,
}

var TypeSlice = []string{
	TypeA, TypeB, TypeC, TypeD,
}

var LogTypeSlice = []string{
	LogTypeAdd,
	LogTypeDelete,
	LogTypeFinish,
	LogTypeModify,
	LogTypeMove,
	LogTypeBegin,
}

func GetTypeData(val string, lastTime int64) TypeData {
	var typeData TypeData
	typeData.Val = val
	typeData.LastTime = lastTime
	typeData.CreateTime = SeTime()
	typeData.UniqId = MsTime()
	return typeData
}
